package org.ccay.audit.service.impl;

import java.util.List;

import javax.inject.Inject;
import javax.inject.Named;

import org.ccay.async.AsyncMessage;
import org.ccay.async.IMessageSender;
import org.ccay.audit.dao.IAuditLogDao;
import org.ccay.audit.service.ILogService;
import org.ccay.audit.vo.LogVO;
import org.ccay.core.exception.ApplicationException;
import org.ccay.core.util.DaoUtil;

/**
 * 审计日志查询服务的实现
 * 
 * Created：2011-9-8
 * 
 * @author chaowangbang
 * @version:
 */
@Named
public class LogService implements ILogService {
	
	
	/**
	 * 数据字典里用户登录时间段URL
	 */
	private static final String URL ="Ccay.Logs.LoginQueryDateArea";
	
	@Inject
	private IAuditLogDao logDao;
	

	/** 异步处理器 **/
	@Inject
	private IMessageSender messageSender;
	/*
	 * (non-Javadoc)
	 * 
	 * @see org.ccay.log.service.ILogService#createLog(org.ccay.log.LogVO)
	 */
	public void createLog(LogVO logVO) throws ApplicationException {
		DaoUtil.assertEffected(logDao.createAuditLog(logVO), "Audit Log");
	}


	/* (non-Javadoc)
	 * @see org.ccay.log.service.ILogService#createLogList(java.util.List)
	 */
	public void createLogList(List<LogVO> logs) throws ApplicationException {
		logDao.createAuditLogList(logs);
	}
	

	/**
	 * 提供异步新增日志的方法
	 */
	public void asyncCreateLog(LogVO logVO) throws ApplicationException {
		AsyncMessage asyncMessage = new AsyncMessage("AuditLog");
		asyncMessage.setContent(logVO);
		messageSender.send(asyncMessage);
	}
}
